export class Const {
  static commonUrl = '/banksearchSystem';
  // static commonUrl = '';
  static NIReg = /^[1-9]\d{7}((0\d)|(1[0-2]))(([0|1|2]\d)|3[0-1])\d{3}$|^[1-9]\d{5}[1-9]\d{3}((0\d)|(1[0-2]))(([0|1|2]\d)|3[0-1])\d{3}([0-9]|X)$/;
  static PPReg = /^([a-zA-z]|[0-9]){5,17}$/;
  static IDReg = /^[\u4E00-\u9FA5](字第)([0-9a-zA-Z]{4,8})(号?)$/;
  static idNoValidator = (idType, value, callback) => {
    if (idType === 'NI') {
      if (Const.NIReg.test(value)) {
        callback();
      } else {
        callback('身份证格式有误');
      }
    } else if (idType === 'PP,PSPT') {
      if (Const.PPReg.test(value)) {
        callback();
      } else {
        callback('护照格式有误');
      }
    } else if (idType === 'ID') {
      // if (Const.IDReg.test(value)) {
      //   callback();
      // } else {
      //   callback('军官证格式有误');
      // }
      callback();
    } else if (idType === 'UU') {
      callback();
    } else {
      callback('请选择证件类型');
    }
  };
  static phoneReg = /^1[3|4|5|8]\d{9}$/;
  static phoneMobileReg = /(^1[3|4|5|8]\d{9}$)|(^(0\d{9,11})?$)/;
  static chineseReg = /^[\u4e00-\u9fa5]{0,}$/;
  static inputNumMax = 99999;
  static formLayout = {
    labelCol: {
      span: 6,
    },
    wrapperCol: {
      span: 14,
    }
  };
  static formLayoutTwo = {
    labelCol: {
      span: 3,
    },
    wrapperCol: {
      span: 19,
    }
  };
  static formLayoutThree = {
    labelCol: {
      span: 12,
    },
    wrapperCol: {
      span: 12,
    }
  };
  static formLayoutFour = {
    labelCol: {
      span: 6,
    },
    wrapperCol: {
      span: 18,
    }
  };
  static format = "YYYY-MM-DD";
  static tooltipColor = 'rgba(0, 0, 0, .45)';
  static dealMap = (arr) => {
    let obj = {};
    for (let item of arr) {
      obj[item.value] = {
        text: item.label
      }
    };
    return obj;
  };
  // 事故单类型
  static accidentTypeList = [
    { label: '进港破损', value: 1 },
    { label: '进港少收', value: 2 },
    { label: '进港多收', value: 3 },
    { label: '进港内物缺失', value: 6 },
    { label: '出港破损', value: 7 },
  ];
  static accidentTypeMap = Const.dealMap(Const.accidentTypeList);
  // 证件类型
  static idTypeListForSearch = [
    { label: '身份证', value: 'NI' },
    { label: '护照', value: 'PP,PSPT' },
    // { label: '护照', value: 'PSPT' },
    { label: '军官证', value: 'ID' },
    { label: '其他', value: 'UU' }
  ];
  static idTypeList = [
    { label: '身份证', value: 'NI' },
    { label: '护照', value: 'PP' },
    { label: '护照', value: 'PSPT' },
    { label: '军官证', value: 'ID' },
    { label: '其他', value: 'UU' }
  ];
  static idTypeMap = {
    'NI': { text: '身份证' },
    'PP': { text: '护照' },
    'PSPT': { text: '护照' },
    'ID': { text: '军官证' },
    'UU': { text: '其他' },
    'CC': { text: '信用卡' },
    'PP,PSPT': { text: '护照' },
  };
  static dealIdType = (val) => {
    if (val) {
      if (val === 'PP' || val === 'PSPT') {
        return 'PP,PSPT';
      } else {
        return val;
      }
    } else {
      return '';
    }
  };
  // 航班号处理
  static formatFlightNo = val => {
    if (!val) {
      return '';
    } else if (val.length < 3 || /^\D/.test(val)) {
      return ''.toUpperCase.call(val);
    } else if (/^\d{2}/.test(val)) {
      return `3U${val}`;
    } else {
      return val;
    }
  };
  // 结案状态 0处理中 1已结案 2待处理 3已作废
  static jieanStatusList = [
    { label: '处理中', value: '0' },
    { label: '已结案', value: '1' },
    { label: '待处理', value: '2' },
    { label: '已作废', value: '3' },
    // { label: 'H5草稿箱', value: '4' },
  ];
  static jieAnStatusMap = Const.dealMap(Const.jieanStatusList);
  static pkgStautsList = [
    { label: '未结案', value: '0' },
    { label: '已结案', value: '1' },
  ];
  static pkgStautsMap = Const.dealMap(Const.pkgStautsList);
  // 格式化大写字母
  static toUpperCaseFormat = val => {
    if (val) {
      return val.toUpperCase();
    } else {
      return val;
    }
  };
  // 少收类型
  static littlePkgTypeList = [
    { label: '常规', value: '常规' },
    { label: '自定义', value: '自定义' },
  ];
  static littlePkgTypeMap = Const.dealMap(Const.littlePkgTypeList);
  // 少收图片类型
  static shaoShouImgListMap = {
    2: {
      text: '旅客相关',
      children: {
        2: '身份证',
        15: '护照',
        10: '其他',
      }
    },
    3: {
      text: '单据相关',
      children: {
        9: '旅客授权签字图',
        8: '快递单',
        11: '事故单',
        12: '物品清单',
        13: '临时赔偿单',
        14: '结案赔偿单',
      }
    },
    4: {
      text: '行李相关',
      children: {
        18: '行李照片',
        20: '物品价值证明',
        10: '其他',
      }
    }
  };
  // 破损图片类型
  static poSunImgListMap = {
    4: {
      text: '行李相关',
      children: {
        21: '行李破损图',
        22: '行李整体图',
      }
    },
    3: {
      text: '单据相关',
      children: {
        16: '污染洗涤发票图',
        17: '破损维修发票图',
        9: '旅客授权签字图',
        8: '快递单',
        11: '事故单',
        14: '结案赔偿单',
      }
    },
    2: {
      text: '旅客相关',
      children: {
        2: '身份证',
        15: '护照',
        10: '其他',
      }
    }
  };
  // 多收图片类型
  static duoShouImgListMap = {
    4: {
      text: '行李相关',
      children: {
        22: '行李整体图'
      }
    },
    3: {
      text: '单据相关',
      children: {
        19: '旅客自提确认单',
        23: '托运物品申请单',
        8: '快递单',
      }
    },
    2: {
      text: '旅客相关',
      children: {
        2: '身份证',
        15: '护照',
        10: '其他',
      }
    }
  };
  // 内物缺失图片类型
  static neiWuQueShiImgListMap = {
    3: {
      text: '单据相关',
      children: {
        8: '快递单',
        11: '事故单',
        24: '丢失物品清单',
        14: '结案赔偿单',
        9: '旅客授权签字图',
      }
    },
    2: {
      text: '旅客相关',
      children: {
        2: '身份证',
        15: '护照',
        10: '其他',
      }
    }
  };
  // 遗失物品图片类型
  static yiShiWuPinImgListMap = {
    1: {
      text: '物品相关',
      children: {
        1: '遗失物品照片'
      }
    },
    2: {
      text: '旅客相关',
      children: {
        2: '身份证',
        10: '其他',
        3: '委托书',
        4: '登机牌',
      }
    },
    3: {
      text: '单据相关',
      children: {
        5: '认领单',
        6: '上交单',
        7: '遗失物品统计单',
        10: '其他',
        8: '快递单',
        9: '旅客授权签字单',
      }
    }
  };
  // 快递物品图片类型
  static kuaiDiWuPinImgListMap = {
    3: {
      text: '单据相关',
      children: {
        8: '快递单',
      }
    }
  };
  // 二级类别图片名字
  static twoTypeMap = {
    1: "遗失物品照片",
    2: "身份证",
    3: "委托书",
    4: "登机牌",
    5: "认领单",
    6: "上交单",
    7: "遗失物品统计单",
    8: "快递单",
    9: "旅客授权签字图",
    10: "其他",
    11: "事故单",
    12: "物品清单",
    13: "临时赔偿单",
    14: "结案赔偿单",
    15: "护照",
    16: "污染洗涤发票图",
    17: "破损维修发票图",
    18: "行李照片",
    19: "旅客自提确认单",
    20: "物品价值证明",
    21: "行李破损图",
    22: "行李整体图",
    23: "托运物品申请",
    24: "丢失物品清单"
  };
  // 收款银行
  static bankList = ["北京银行", "成都农商银行", "中国邮政储蓄银行", "成都银行", "西安银行", "中国工商银行", "中国农业银行", "中国银行", "中国建设银行", "中国交通银行", "招商银行", "中国民生银行", "中国光大银行", "广东农信佛山农商银行", "南京银行", "兴业银行", "华夏银行", "四川省农村信用合作社"];
  // 省份
  static provinceList = ["河北省", "山西省", "辽宁省", "吉林省", "黑龙江省", "江苏省", "浙江省", "安徽省", "福建省", "江西省", "山东省", "河南省", "湖北省", "湖南省", "广东省", "海南省", "四川省", "贵州省", "云南省", "陕西省", "甘肃省", "青海省", "台湾省", "内蒙古自治区", "广西壮族自治区", "西藏自治区", "宁夏回族自治区", "新疆维吾尔自治区", "北京市", "天津市", "上海市", "重庆市", "香港特别行政区", "澳门特别行政区"];
  // 汇款用途
  static payeeUseList = ["行李少收赔偿", "行李破损赔偿", "行李内物丢失赔偿"];
  static numberChinese (str) {
    let num = parseFloat(str);
    let strOutput = "";
    let strUnit = '仟佰拾亿仟佰拾万仟佰拾元角分';
    num += "00";
    var intPos = num.indexOf('.');
    if (intPos >= 0) {
      num = num.substring(0, intPos) + num.substr(intPos + 1, 2);
    }
    strUnit = strUnit.substr(strUnit.length - num.length);
    for (var i = 0; i < num.length; i++) {
      strOutput += '零壹贰叁肆伍陆柒捌玖'.substr(num.substr(i, 1), 1) + strUnit.substr(i, 1);
    }
    return strOutput.replace(/零角零分$/, '整').replace(/零[仟佰拾]/g, '零').replace(/零{2,}/g, '零').replace(/零([亿|万])/g, '$1').replace(/零+元/, '元').replace(/亿零{0,3}万/, '亿').replace(/^元/, "零元")
  };
  // 事故单原因 1.错运 2.丢失 3.内物缺失 4.其他原因 5.错挂 6 .脱牌 7.漏装 8.卡带 9.减载 10.安扣 11.错提 12.错卸 13.行李破损
  static accidentReasonList = [
    { label: '错运', value: 1 },
    { label: '丢失', value: 2 },
    { label: '内物缺失', value: 3 },
    { label: '其他原因', value: 4 },
    { label: '错挂', value: 5 },
    { label: '脱牌', value: 6 },
    { label: '漏装', value: 7 },
    { label: '卡带', value: 8 },
    { label: '减载', value: 9 },
    { label: '安扣', value: 10 },
    { label: '错提', value: 11 },
    { label: '错卸', value: 12 },
    { label: '行李破损', value: 13 },
  ];
  static accidentReasonMap = Const.dealMap(Const.accidentReasonList);
  // 责任机场
  static dutyTerminalList = [
    { label: '始发站责任', value: 0 },
    { label: '目的站责任', value: 1 },
  ];
  // 支付状态 0未领取 1已领取 2领取中
  static receiveStatusList = [
    { label: '未领取', value: 0 },
    { label: '已领取', value: 1 },
    { label: '领取中', value: 2 },
  ];
  static receiveStatusMap = Const.dealMap(Const.receiveStatusList);
  // 赔偿单状态 0草稿 1审核中 2通过 3生效 4关闭 5未通过 6驳回 7待审核 8逾期
  static statusList = [
    { label: '草稿', value: 0 },
    { label: '审核中', value: 1 },
    { label: '通过', value: 2 },
    { label: '生效', value: 3 },
    { label: '关闭', value: 4 },
    { label: '未通过', value: 5 },
    { label: '驳回', value: 6 },
    { label: '待审核', value: 7 },
    { label: '逾期', value: 8 },
    { label: '注销', value: 9 },
    { label: '箱包已发放', value: 10 },
  ];
  static statusMap = Const.dealMap(Const.statusList);
  // 快递公司列表
  static expressCompanyList = ['顺丰', '百世快递', '圆通', '申通', '邮政', '其他'];
  // 破损类型 1撕裂 2划痕 3压碎 4污染 5凹坑 6洞穿 7其他
  static damageTypeList = [
    { label: '撕裂', value: 1 },
    { label: '划痕', value: 2 },
    { label: '压碎', value: 3 },
    { label: '污染', value: 4 },
    { label: '凹坑', value: 5 },
    { label: '洞穿', value: 6 },
    { label: '其他', value: 7 },
  ];
  static damageTypeMap = Const.dealMap(Const.damageTypeList);
  // 破损程度 1全部 2大面积 3小面积
  static damageLevelList = [
    { label: '全部', value: 1 },
    { label: '大面积', value: 2 },
    { label: '小面积', value: 3 },
  ];
  static damageLevelMap = Const.dealMap(Const.damageLevelList);
  // 破损部位 1箱体 2把手 3锁 4拉杆 5轮子 6其他
  static damagePartList = [
    { label: '箱体', value: 1 },
    { label: '把手', value: 2 },
    { label: '锁', value: 3 },
    { label: '拉杆', value: 4 },
    { label: '轮子', value: 5 },
    { label: '其他', value: 6 },
  ];
  static damagePartMap = Const.dealMap(Const.damagePartList);
  // 赔偿单审核流程详情 0通过 1不同意 2驳回 3发起
  static opinionList = [
    { label: '通过', value: 0 },
    { label: '不同意', value: 1 },
    { label: '驳回', value: 2 },
    { label: '发起', value: 3 },
  ];
  static opinionMap = Const.dealMap(Const.opinionList);
  // 行李属性
  static pkgPropertyList = [
    { label: '旅客行李', value: '旅客行李' },
    { label: '内部托运行李', value: '内部托运行李' },
    { label: '捎买带行李', value: '捎买带行李' },
    { label: '外站退回', value: '外站退回' },
    { label: '掉条', value: '掉条' },
    { label: '其他', value: '其他' },
  ];
  static pkgPropertyMap = Const.dealMap(Const.pkgPropertyList);
  // 出库类型
  static outTypeList = [
    { label: '旅客自提', value: 1 },
    { label: '转速运', value: 2 },
    { label: '转遗失', value: 3 },
    { label: '转快递', value: 4 },
  ];
  static outTypeListNew = [
    { label: '旅客自提', value: 1 },
    { label: '转速运', value: 2 },
    { label: '转遗失', value: 3 },
    { label: '转快递', value: 4 },
    { label: '', value: 5 },
  ];
  static outTypeMap = Const.dealMap(Const.outTypeList);
  static outTypeMapNew = Const.dealMap(Const.outTypeListNew);
  // 自提状态 0已认领 1已联系旅客待认领 2已快递给旅客
  static recipientStatusList = [
    { label: '已认领', value: '0' },
    { label: '已联系旅客待认领', value: '1' },
    { label: '已快递给旅客', value: '2' },
  ];
  static recipientStatusMap = Const.dealMap(Const.recipientStatusList);
  static setIsNeedGetList = (type) => {
    let obj = {};
    if (sessionStorage.getItem('isNeedGetBaggageList')) {
      obj = JSON.parse(sessionStorage.getItem('isNeedGetBaggageList'));
      obj[type] = 1;
    } else {
      obj[type] = 1;
    }

    sessionStorage.setItem('isNeedGetBaggageList', JSON.stringify(obj));
  };
  static getIsNeedGetList = (type) => {
    if (sessionStorage.getItem('isNeedGetBaggageList')) {
      let obj = JSON.parse(sessionStorage.getItem('isNeedGetBaggageList'));
      if (+obj[type] === 1) {
        obj[type] = 0;
        sessionStorage.setItem('isNeedGetBaggageList', JSON.stringify(obj));
        return true;
      } else {
        return false;
      }
    } else {
      return false;
    }
  };
  // 计算处理最大字符数
  static dealStrNum = (str, maxNum) => {
    str = str + '';
    let arr = str.split('');
    let num = 0;
    for (let item of arr) {
      if (Const.chineseReg.test(item)) {
        num += 2;
      } else {
        num++;
      }
    }
    if (num <= maxNum) {
      return true;
    } else {
      return false;
    }
  }
  static permissionsType = new Map()
    .set(1, 'damagedLuggage')
    .set(2, 'lessLuggage')
    .set(3, 'moreLuggage')
    .set(6, 'internalMissingLuggage')
    .set(7, 'outDamagedLuggage');
}
